home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / VBSamples / Demos / AirHockey / frmAir.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2001-10-08  |  19.5 KB  |  484 lines

  1. VERSION 5.00
  2. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  3. Begin VB.Form frmAir 
  4.    BackColor       =   &H00000000&
  5.    BorderStyle     =   1  'Fixed Single
  6.    Caption         =   "Air Hockey"
  7.    ClientHeight    =   4500
  8.    ClientLeft      =   45
  9.    ClientTop       =   330
  10.    ClientWidth     =   6000
  11.    BeginProperty Font 
  12.       Name            =   "Comic Sans MS"
  13.       Size            =   9.75
  14.       Charset         =   0
  15.       Weight          =   700
  16.       Underline       =   0   'False
  17.       Italic          =   0   'False
  18.       Strikethrough   =   0   'False
  19.    EndProperty
  20.    Icon            =   "frmAir.frx":0000
  21.    KeyPreview      =   -1  'True
  22.    LinkTopic       =   "Form1"
  23.    MaxButton       =   0   'False
  24.    MinButton       =   0   'False
  25.    ScaleHeight     =   300
  26.    ScaleMode       =   3  'Pixel
  27.    ScaleWidth      =   400
  28.    StartUpPosition =   2  'CenterScreen
  29.    Begin MSComctlLib.ProgressBar barProg 
  30.       Height          =   540
  31.       Left            =   225
  32.       TabIndex        =   0
  33.       Top             =   3390
  34.       Visible         =   0   'False
  35.       Width           =   5490
  36.       _ExtentX        =   9684
  37.       _ExtentY        =   953
  38.       _Version        =   393216
  39.       Appearance      =   1
  40.       Scrolling       =   1
  41.    End
  42.    Begin VB.Label lblSplash 
  43.       Alignment       =   2  'Center
  44.       BackStyle       =   0  'Transparent
  45.       Caption         =   "Visual Basic Air Hockey, loading...."
  46.       ForeColor       =   &H00FFFFFF&
  47.       Height          =   360
  48.       Left            =   1095
  49.       TabIndex        =   1
  50.       Top             =   390
  51.       Visible         =   0   'False
  52.       Width           =   4110
  53.    End
  54.    Begin VB.Image imgSplash 
  55.       Height          =   4395
  56.       Left            =   30
  57.       Picture         =   "frmAir.frx":030A
  58.       Stretch         =   -1  'True
  59.       Top             =   60
  60.       Visible         =   0   'False
  61.       Width           =   5925
  62.    End
  63. Attribute VB_Name = "frmAir"
  64. Attribute VB_GlobalNameSpace = False
  65. Attribute VB_Creatable = False
  66. Attribute VB_PredeclaredId = True
  67. Attribute VB_Exposed = False
  68. Option Explicit
  69. 'Sleep declare
  70. Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
  71. Private Enum SplashScreenMode
  72.     SplashShow
  73.     SplashHide
  74.     SplashResize
  75. End Enum
  76. 'We need to implement our event interfaces
  77. Implements DirectPlay8Event
  78. Private mlSendTime As Long
  79. Private mlNumSend As Long
  80. Private mfGotGameSettings As Boolean
  81. Private mfGameStarted As Boolean
  82. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  83.     'We need to be able to handle F2 keys for resolution changes
  84.      Select Case KeyCode
  85.      Case vbKeyF2
  86.         PauseSystem True
  87.         goDev.SelectDevice Me
  88.     Case vbKeyF1
  89.         'Toggle the ability to draw the room
  90.         goRoom.DrawRoom = Not goRoom.DrawRoom
  91.     Case vbKeyF4
  92.         'Toggle the transparency of the paddles
  93.         goTable.Transparent = Not goTable.Transparent
  94.     Case vbKeyF5
  95.         'Toggle the ability to draw the room
  96.         goTable.DrawTable = Not goTable.DrawTable
  97.     Case vbKeyF6
  98.         'Toggle the transparency of the paddles
  99.         goPaddle(0).Transparent = Not goPaddle(0).Transparent
  100.         goPaddle(1).Transparent = Not goPaddle(1).Transparent
  101.     Case vbKeyF3
  102.         'Restart the game if it's available
  103.         If gfGameOver Then
  104.             gPlayer(0).Score = 0: gPlayer(1).Score = 0
  105.             goPuck.DefaultStartPosition
  106.             gfGameOver = False
  107.             NotifyGameRestart
  108.         End If
  109.     Case vbKeyReturn
  110.         ' Check for Alt-Enter if not pressed exit
  111.         If Shift <> 4 Then Exit Sub
  112.         PauseSystem True
  113.         ' If we are windowed go fullscreen
  114.         ' If we are fullscreen returned to windowed
  115.         SaveOrRestoreObjectSettings True
  116.         InvalidateDeviceObjects
  117.         Cleanup True, True
  118.         If g_d3dpp.Windowed Then
  119.              D3DUtil_ResetFullscreen
  120.         Else
  121.              D3DUtil_ResetWindowed
  122.         End If
  123.         
  124.         ' Call Restore after ever mode change
  125.         ' because calling reset looses state that needs to
  126.         ' be reinitialized
  127.         Me.RestoreDeviceObjects False
  128.         SaveOrRestoreObjectSettings False
  129.         PauseSystem False
  130.     End Select
  131. End Sub
  132. Private Sub Form_KeyPress(KeyAscii As Integer)
  133.     Dim nVel As Single
  134.     Dim vNewVel As D3DVECTOR
  135.     If KeyAscii = vbKeyEscape Then
  136.         Unload Me
  137.     ElseIf LCase(Chr$(KeyAscii)) = "v" Then
  138.         'Scroll through the different 'default' views.  If there is currently a custom view on
  139.         'turn on the default view.
  140.         goCamera.NextCameraPosition glMyPaddleID
  141.     ElseIf KeyAscii = vbKeySpace Then
  142.         'We want to launch the puck.  We should only be able to do this if
  143.         'we have recently scored, or if we haven't started the game yet.
  144.         If gfGameCanBeStarted And gfScored And (Not gfGameOver) Then
  145.             goPuck.LaunchPuck
  146.             If gfMultiplayer Then
  147.                 SendPuck
  148.             End If
  149.             'Start the puck spinning
  150.             goPuck.Spinning = True
  151.             gfScored = False
  152.             glTimeCompPaddle = 0
  153.         End If
  154.     ElseIf LCase(Chr$(KeyAscii)) = "w" Then
  155.         gfWireFrame = Not gfWireFrame
  156.     'These two cases should be removed in the final version
  157.     ElseIf LCase(Chr$(KeyAscii)) = "+" Then
  158.         If Not gfScored Then
  159.             nVel = D3DXVec3Length(goPuck.Velocity) * 1.2
  160.             D3DXVec3Normalize vNewVel, goPuck.Velocity
  161.             D3DXVec3Scale vNewVel, vNewVel, nVel
  162.             goPuck.Velocity = vNewVel
  163.             SendPuck
  164.         End If
  165.     ElseIf LCase(Chr$(KeyAscii)) = "-" Then
  166.         If Not gfScored Then
  167.             nVel = D3DXVec3Length(goPuck.Velocity) * 0.8
  168.             D3DXVec3Normalize vNewVel, goPuck.Velocity
  169.             D3DXVec3Scale vNewVel, vNewVel, nVel
  170.             goPuck.Velocity = vNewVel
  171.             SendPuck
  172.         End If
  173.     End If
  174. End Sub
  175. Private Sub Form_Load()
  176.     glMyPaddleID = 0
  177.     mfGotGameSettings = False
  178.     'We've got here now.  Go ahead and init our 3D device
  179.     If gfMultiplayer Then
  180.         'Oh good, we want to play a multiplayer game.
  181.         'First lets get the dplay connection started
  182.         
  183.         'Here we will init our DPlay objects
  184.         InitDPlay
  185.         'Now we can create a new Connection Form (which will also be our message pump)
  186.         Set DPlayEventsForm = New DPlayConnect
  187.         'Start the connection form (it will either create or join a session)
  188.         If Not DPlayEventsForm.StartConnectWizard(dx, dpp, AppGuid, 2, Me, False) Then
  189.             CleanupDPlay
  190.             End
  191.         Else 'We did choose to play a game
  192.             gsUserName = DPlayEventsForm.UserName
  193.             If DPlayEventsForm.IsHost Then
  194.                 Me.Caption = Me.Caption & " (HOST)"
  195.                 mfGotGameSettings = True
  196.             End If
  197.             gfHost = DPlayEventsForm.IsHost
  198.         End If
  199.     End If
  200.         
  201.     'Do a quick switch to windowed mode just to initialize all the vars
  202.     If Not D3DUtil_Init(frmAir.hwnd, True, 0, 0, D3DDEVTYPE_HAL, Me) Then
  203.         MsgBox "Could not initialize Direct3D.  This sample will now exit", vbOKOnly Or vbInformation, "Exiting..."
  204.         Unload Me
  205.         Exit Sub
  206.     End If
  207.     'Now update to the 'correct' resolution (or windowed)
  208.     goDev.UpdateNow Me
  209.     glScreenHeight = Me.ScaleHeight: glScreenWidth = Me.ScaleWidth
  210.     If g_d3dpp.Windowed = 0 Then
  211.         Me.Move 0, 0, g_d3dpp.BackBufferWidth * Screen.TwipsPerPixelX, g_d3dpp.BackBufferHeight * Screen.TwipsPerPixelY
  212.     End If
  213.     Me.Show
  214.     SplashScreenMode SplashShow
  215.     DoEvents
  216.     barProg.Min = 0: barProg.Max = 9
  217.     InitDeviceObjects
  218.     IncreaseProgressBar
  219.     RestoreDeviceObjects
  220.     IncreaseProgressBar
  221.     'Start up our Input devices
  222.     If Not goInput.InitDirectInput(Me) Then
  223.         Cleanup 'This should restore our state so we can complain that we couldn't Init Dinput
  224.         MsgBox "Unable to Initialize DirectInput, this sample will now exit.", vbOKOnly Or vbInformation, "No DirectInput"
  225.         Unload Me
  226.         Exit Sub
  227.     End If
  228.     IncreaseProgressBar
  229.     'Start up our sounds
  230.     If Not goAudio.InitAudio Then
  231.         MsgBox "Unable to Initialize Audio, this sample will not have audio capablities.", vbOKOnly Or vbInformation, "No Audio"
  232.         goAudio.PlayMusic = False
  233.         goAudio.PlaySounds = False
  234.     End If
  235.     IncreaseProgressBar
  236.     'Here we will load the initial positions for our objects
  237.     LoadDefaultStartPositions
  238.     'Get rid of the splash screen
  239.     Unload frmSplash
  240.     glTimePuckScored = timeGetTime
  241.     SplashScreenMode SplashHide
  242.     'Wait a brief period of time
  243.     Sleep 100
  244.     'Do the intro
  245.     ShowStartup
  246.     goAudio.StartBackgroundMusic
  247.     glTimePuckScored = timeGetTime
  248.     Me.Show
  249.     'Start the puck spinning
  250.     goPuck.Spinning = True
  251.     'Now, if we're in a multiplayer game, and we're the client
  252.     'let the host know that we are ready to play the game, and he can launch the puck at any time.
  253.     If gfMultiplayer Then
  254.         Do While Not mfGotGameSettings
  255.             DPlayEventsForm.DoSleep 10 'Wait until we receive the game settings
  256.         Loop
  257.         NotifyClientReady
  258.     End If
  259.     glTimePuckScored = timeGetTime
  260.     MainGameLoop
  261. End Sub
  262. Private Sub Form_Resize()
  263.     If Me.WindowState = vbMinimized Then
  264.         PauseSystem True
  265.     Else
  266.         PauseSystem False
  267.         glScreenHeight = Me.ScaleHeight: glScreenWidth = Me.ScaleWidth
  268.         SplashScreenMode SplashResize
  269.     End If
  270. End Sub
  271. Private Sub Form_Unload(Cancel As Integer)
  272.     goFade.Fade -5
  273.     Do While goFade.AmFading
  274.         Render
  275.         goFade.UpdateFade goPuck, goPaddle, goTable, goRoom
  276.         DoEvents
  277.     Loop
  278.     SaveDrawingSettings
  279.     CleanupDPlay
  280.     Cleanup True
  281.     End
  282. End Sub
  283. Private Sub SaveDrawingSettings()
  284.     SaveSetting gsKeyName, gsSubKey, "DrawRoom", goRoom.DrawRoom
  285.     SaveSetting gsKeyName, gsSubKey, "DrawTable", goTable.DrawTable
  286. End Sub
  287. Public Function VerifyDevice(flags As Long, format As CONST_D3DFORMAT) As Boolean
  288.     'All the checks we care about are already done, always return true
  289.     VerifyDevice = True
  290. End Function
  291. Public Sub InvalidateDeviceObjects()
  292.     InitDeviceObjects False
  293. End Sub
  294. Public Sub RestoreDeviceObjects(Optional ByVal fSplash As Boolean = True)
  295.     modAirHockey.RestoreDeviceObjects
  296.     InitDeviceObjects (Not fSplash)
  297.     glScreenHeight = Me.ScaleHeight: glScreenWidth = Me.ScaleWidth
  298.     If fSplash Then SplashScreenMode SplashResize
  299. End Sub
  300. Public Sub DeleteDeviceObjects()
  301.     Cleanup
  302. End Sub
  303. Public Sub InitDeviceObjects(Optional fLoadGeometry As Boolean = True)
  304.     'Check caps for lights
  305.     Dim d3dcaps As D3DCAPS8
  306.     g_dev.GetDeviceCaps d3dcaps
  307.     If (d3dcaps.VertexProcessingCaps And D3DVTXPCAPS_DIRECTIONALLIGHTS) <> 0 Then  'We can use directional lights
  308.         InitDefaultLights d3dcaps.MaxActiveLights 'Set up the lights for the room
  309.     Else
  310.         'We could render the whole scene just using ambient light
  311.         '(which we'll have too since we can't position our direction
  312.         'lights), but the user will miss out on the shading of the table
  313.         InitDefaultLights 0 'Set up a default ambiant only light
  314.     End If
  315.     'Make sure the device supports alpha blending
  316.     If (d3dcaps.TextureCaps And D3DPTEXTURECAPS_ALPHA) Then
  317.         If Not (goFade Is Nothing) Then goFade.CanFade = True
  318.         g_dev.SetRenderState D3DRS_ALPHABLENDENABLE, 1
  319.     Else
  320.         If Not (goFade Is Nothing) Then goFade.CanFade = False
  321.     End If
  322.     'Load our objects now
  323.     If fLoadGeometry Then InitGeometry 'Set up the room geometry
  324. End Sub
  325. Public Sub IncreaseProgressBar()
  326.     On Error Resume Next
  327.     barProg.Value = barProg.Value + 1
  328.     DoEvents
  329. End Sub
  330. Private Sub SplashScreenMode(ByVal Mode As SplashScreenMode)
  331.     Select Case Mode
  332.     Case SplashHide
  333.         imgSplash.Visible = False
  334.         barProg.Visible = False
  335.         lblSplash.Visible = False
  336.     Case SplashResize
  337.         'Move the splash screen to cover the entire client area
  338.         imgSplash.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight
  339.         'Move the progress bar
  340.         barProg.Move 15, Me.ScaleHeight - ((Me.ScaleHeight / 10) + 20), Me.ScaleWidth - 30, Me.ScaleHeight / 10
  341.         lblSplash.Move 15, ((Me.ScaleHeight / 10) + 20), Me.ScaleWidth - 30, Me.ScaleHeight / 10
  342.     Case SplashShow
  343.         imgSplash.Visible = True
  344.         barProg.Visible = True
  345.         lblSplash.Visible = True
  346.         lblSplash.ZOrder
  347.     End Select
  348. End Sub
  349. Private Sub DirectPlay8Event_AddRemovePlayerGroup(ByVal lMsgID As Long, ByVal lPlayerID As Long, ByVal lGroupID As Long, fRejectMsg As Boolean)
  350.     'VB requires that we implement *all* members of an interface
  351. End Sub
  352. Private Sub DirectPlay8Event_AppDesc(fRejectMsg As Boolean)
  353.     'VB requires that we implement *all* members of an interface
  354. End Sub
  355. Private Sub DirectPlay8Event_AsyncOpComplete(dpnotify As DxVBLibA.DPNMSG_ASYNC_OP_COMPLETE, fRejectMsg As Boolean)
  356.     'VB requires that we implement *all* members of an interface
  357. End Sub
  358. Private Sub DirectPlay8Event_ConnectComplete(dpnotify As DxVBLibA.DPNMSG_CONNECT_COMPLETE, fRejectMsg As Boolean)
  359.     If dpnotify.hResultCode <> 0 Then 'There was a problem
  360.         MsgBox "Failed to connect to host." & vbCrLf & "Error:" & CStr(dpnotify.hResultCode), vbOKOnly Or vbInformation, "Exiting..."
  361.         Unload Me
  362.         Exit Sub
  363.     End If
  364.     'If we are receiving this event we must know that we are the client, since the server never receives this message.
  365.     'Make sure we are assigned paddle ID #1
  366.     glMyPaddleID = 1 'We are the second paddle
  367. End Sub
  368. Private Sub DirectPlay8Event_CreateGroup(ByVal lGroupID As Long, ByVal lOwnerID As Long, fRejectMsg As Boolean)
  369.     'VB requires that we implement *all* members of an interface
  370. End Sub
  371. Private Sub DirectPlay8Event_CreatePlayer(ByVal lPlayerID As Long, fRejectMsg As Boolean)
  372.     'We've got the create player message, so someone has just joined.  Send them the
  373.     'Setup message (if it's not us)
  374.     Dim dpPlayer As DPN_PLAYER_INFO
  375.     dpPlayer = dpp.GetPeerInfo(lPlayerID)
  376.     If (dpPlayer.lPlayerFlags And DPNPLAYER_HOST) = 0 Then 'This isn't the host, let them know
  377.         SendGameSettings
  378.     End If
  379.     If (dpPlayer.lPlayerFlags And DPNPLAYER_LOCAL) = 0 Then 'This isn't the local player, save this id
  380.         glOtherPlayerID = lPlayerID
  381.     End If
  382. End Sub
  383. Private Sub DirectPlay8Event_DestroyGroup(ByVal lGroupID As Long, ByVal lReason As Long, fRejectMsg As Boolean)
  384.     'VB requires that we implement *all* members of an interface
  385. End Sub
  386. Private Sub DirectPlay8Event_DestroyPlayer(ByVal lPlayerID As Long, ByVal lReason As Long, fRejectMsg As Boolean)
  387.     'If we receive a DestroyPlayer msg, then the other player must have quit.
  388.     'We have been disconnected, stop sending data
  389.     gfNoSendData = True
  390. End Sub
  391. Private Sub DirectPlay8Event_EnumHostsQuery(dpnotify As DxVBLibA.DPNMSG_ENUM_HOSTS_QUERY, fRejectMsg As Boolean)
  392.     'If the game has started don't even bother answering the enum query.
  393.     If mfGameStarted Then fRejectMsg = True
  394. End Sub
  395. Private Sub DirectPlay8Event_EnumHostsResponse(dpnotify As DxVBLibA.DPNMSG_ENUM_HOSTS_RESPONSE, fRejectMsg As Boolean)
  396.     'VB requires that we implement *all* members of an interface
  397. End Sub
  398. Private Sub DirectPlay8Event_HostMigrate(ByVal lNewHostID As Long, fRejectMsg As Boolean)
  399.     'VB requires that we implement *all* members of an interface
  400. End Sub
  401. Private Sub DirectPlay8Event_IndicateConnect(dpnotify As DxVBLibA.DPNMSG_INDICATE_CONNECT, fRejectMsg As Boolean)
  402.     If Not mfGameStarted Then
  403.         'We haven't started the game yet, go ahead and allow this
  404.         mfGameStarted = True
  405.     Else
  406.         fRejectMsg = True
  407.     End If
  408. End Sub
  409. Private Sub DirectPlay8Event_IndicatedConnectAborted(fRejectMsg As Boolean)
  410.     'Uh oh, the person who indicated connect has now aborted, reset our flag
  411.     fRejectMsg = False
  412. End Sub
  413. Private Sub DirectPlay8Event_InfoNotify(ByVal lMsgID As Long, ByVal lNotifyID As Long, fRejectMsg As Boolean)
  414.     'VB requires that we implement *all* members of an interface
  415. End Sub
  416. Private Sub DirectPlay8Event_Receive(dpnotify As DxVBLibA.DPNMSG_RECEIVE, fRejectMsg As Boolean)
  417.     'process what msgs we receive.
  418.     Dim lMsg As Byte, lOffset As Long
  419.     Dim lPaddleID As Byte
  420.     Dim vTemp As D3DVECTOR
  421.     With dpnotify
  422.     GetDataFromBuffer .ReceivedData, lMsg, LenB(lMsg), lOffset
  423.     Select Case lMsg
  424.     Case MsgPaddleLocation
  425.         GetDataFromBuffer .ReceivedData, lPaddleID, LenB(lPaddleID), lOffset
  426.         GetDataFromBuffer .ReceivedData, vTemp, LenB(vTemp), lOffset
  427.         goPaddle(lPaddleID).Position = vTemp
  428.     Case MsgPuckLocation
  429.         GetDataFromBuffer .ReceivedData, vTemp, LenB(vTemp), lOffset
  430.         goPuck.Position = vTemp
  431.         GetDataFromBuffer .ReceivedData, vTemp, LenB(vTemp), lOffset
  432.         goPuck.Velocity = vTemp
  433.         'Start the puck spinning
  434.         goPuck.Spinning = True
  435.         gfScored = False
  436.     Case MsgClientConnectedAndReadyToPlay
  437.         gfGameCanBeStarted = True
  438.     Case MsgPlayerScored
  439.         goPuck.DropPuckIntoScoringPosition goAudio, True
  440.     Case MsgRestartGame
  441.         If gfGameOver Then
  442.             gPlayer(0).Score = 0: gPlayer(1).Score = 0
  443.             goPuck.DefaultStartPosition
  444.             gfGameOver = False
  445.         End If
  446.     Case MsgSendGameSettings
  447.         'Get the data that holds the game settings
  448.         GetDataFromBuffer .ReceivedData, gnVelocityDamp, LenB(gnVelocityDamp), lOffset
  449.         goPuck.MaximumPuckVelocity = gnVelocityDamp * 6.23
  450.         GetDataFromBuffer .ReceivedData, glUserWinningScore, LenB(glUserWinningScore), lOffset
  451.         GetDataFromBuffer .ReceivedData, gnPaddleMass, LenB(gnPaddleMass), lOffset
  452.         mfGotGameSettings = True
  453.     Case MsgCollidePaddle
  454.         'Notify the user that the puck hit the paddle by playing a sound
  455.         goAudio.PlayHitSound
  456.     End Select
  457.     End With
  458. End Sub
  459. Private Sub DirectPlay8Event_SendComplete(dpnotify As DxVBLibA.DPNMSG_SEND_COMPLETE, fRejectMsg As Boolean)
  460.     'Here we can update our send frequency based on how quickly the messages are arriving
  461.     mlSendTime = mlSendTime + dpnotify.lSendTime
  462.     mlNumSend = mlNumSend + 1
  463.     If dpnotify.hResultCode = DPNERR_TIMEDOUT Then
  464.         'Add a little more delay, packets are timing out
  465.         mlSendTime = mlSendTime + dpnotify.lSendTime + (glMinimumSendFrequency \ 2)
  466.     End If
  467.     'Send them as fast as they can receive them, but not overly fast (20 times/second max)
  468.     'We will calculate this based on the average amount of time it takes to send the data
  469.     glSendFrequency = ((mlSendTime \ mlNumSend) + glSendFrequency) \ 2
  470.     Debug.Print "Send Freq:"; glSendFrequency; mlSendTime; mlNumSend
  471.     glOneWaySendLatency = (mlSendTime \ mlNumSend) \ 2
  472.     If glSendFrequency < glMinimumSendFrequency Then glSendFrequency = glMinimumSendFrequency
  473.     'Check for the max value for long (just in case)
  474.     If (mlNumSend > 2147483647) Or (mlSendTime > 2147483647) Then 'You would have to run the app for like 3 years to reach this level, but just in case...
  475.         'If it does though, reset the average
  476.         mlNumSend = 0
  477.         mlSendTime = 0
  478.     End If
  479. End Sub
  480. Private Sub DirectPlay8Event_TerminateSession(dpnotify As DxVBLibA.DPNMSG_TERMINATE_SESSION, fRejectMsg As Boolean)
  481.     'We have been disconnected, stop sending data
  482.     gfNoSendData = True
  483. End Sub
  484.